﻿using System;
using System.Collections.Generic;
using System.Globalization;
using Locator.LcboServices.PageLoaders.Properties;
using System.Net;


namespace Locator.LcboServices.PageLoaders.PageRetrievers
{
    internal class TestInventoryPageRetriever : PageRetriever
    {
        private readonly static List<string> knownProductIds = new List<string>() { "904409", "198069", "53884" };
        protected override Uri BuildUrl(string parameter)
        {
            string myParameter;
            if (knownProductIds.Contains(parameter))
            {
                myParameter = parameter;
            }
            else
            {
                myParameter = String.Empty;
            }

            Uri theUri = new Uri(String.Format(CultureInfo.InvariantCulture, "http://localhost.:{0}/productlocations{1}.aspx", Resources.TestWebPort, myParameter));
            return theUri;
        }

        protected override string PostParameters
        {
            get { return String.Empty; }
        }

        protected override string RequestMethod
        {
            get { return WebRequestMethods.Http.Get; }
        }

        protected override HttpWebRequest BuildRequest(string parameter)
        {
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(BuildUrl(parameter));
            request.Method = WebRequestMethods.Http.Get;
            request.Accept = "text/html";
            request.Headers.Add("Accept-Encoding", "gzip,deflate");
            return request;
        }

        protected override HttpWebRequest BuildRequestAsync(string parameter)
        {
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(BuildUrl(parameter));
            request.Method = WebRequestMethods.Http.Get;
            request.Accept = "text/html";
            request.Headers.Add("Accept-Encoding", "gzip,deflate");
            return request;
        }

    }
}
